/* //device/system/broncho-ril/ril_util.h
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

#ifndef RIL_UTIL_H
#define RIL_UTIL_H

#ifdef __cplusplus
extern "C" {
#endif

typedef enum
{
	PORT_TYPE_SOCKET,
	PORT_TYPE_SERIAL,
	PORT_TYPE_PTY,
	PORT_TYPE_LOOPBACK,
	PORT_TYPE_NR
}RilPortType;

int ril_open_port(RilPortType type, const char* port_name);
void sleep_msec(long long msec);

int strStartsWith(const char *line, const char *prefix);
int at_line_scanf_string (char* p_cur, char** pp_out);
int at_line_scanf_int_int_int_int_int (char* p_cur, int* p_out1, int* p_out2, 
		int* p_out3, int* p_out4, int* p_out5);
int at_line_scanf_int_int_int_int(char* p_cur, int* p_out1, int* p_out2, 
		int* p_out3, int* p_out4);
int at_line_scanf_int_int (char* p_cur, int* p_out1, int* p_out2);
int at_line_scanf_int (char* p_cur, int* p_out);
int at_line_scanf_int_string(char* p_cur, int* p_int, char** pp_str);
int at_line_scanf_int_int_int(char* p_cur, int* p_int1, int* p_int2, int* p_int3);
int at_line_scanf_int_int_string(char* p_cur, int* p_int1, int* p_int2, char** pp_str);
//wupeng add begin.
int at_line_scanf_string_int_int (char* p_cur, char** pp_str, int* p_int1, int* p_int2);
//wupeng add end.
/* broncho yinlijun add begin */
int at_line_scanf_string_int_int_int_int (char* p_cur, char** pp_str, int* p_int1, int* p_int2, int* p_int3, int* p_int4);
void hex_dump(void *data, int size);
/* add end */
int at_line_scanf_string_int_int_int_int_int(char* p_cur, char** pp_str, 
		int* p_int1, int* p_int2, int* p_int3, int* p_int4, int* p_int5);
int at_line_scanf_int_string_int_string_int(char* p_cur, int* p_int1,
		char** p_str1, int* p_int2, char** pp_str2, int* p_int3);
int at_line_scanf_int_int_int_int_int_int_int_int(char* p_cur, int* p_int1, int* p_int2,
		int* p_int3, int* p_int4, int* p_int5, int* p_int6, int* p_int7, int* p_int8);
int at_line_scanf_string_string_string(char* p_cur, char** pp_str1,
		char** pp_str2, char** pp_str3);
int at_line_scanf_string_string_string_string_string_string(char* p_cur, char** pp_str1,
		char** pp_str2, char** pp_str3, char** pp_str4, char** pp_str5, char** pp_str6);

unsigned char 	getuint8(unsigned char* data, unsigned int startBit, 
						unsigned int numBits);
void 			putuint8(unsigned char*data, unsigned short startBit, 
						unsigned char numBits, unsigned char value);
int 			charToBcd(char c);
unsigned char 	bcdToChar(int b);
unsigned char hextodec(unsigned char* pch);
char* 			hexToString(unsigned char *psrc , int srclen);
unsigned char* 	StringToHex(unsigned char *pSrc ,int dSrcLen);
void 			PrintBuffer (const char *name, const unsigned char *buf, int count);

#ifdef __cplusplus
}
#endif

#endif

